<?php
/*
 * 手机客户端拍卖-获取历史竞价接口
 * 2014-06-03
 */
include "../inc/public_header.php";
include "../func/user.php";				//用户信息处理函数
include "../func/bid.php";				//拍卖信息处理函数

//常量
$aid 		= $_REQUEST["aid"];		
$uuid 		= $_REQUEST["uuid"];	
$key 		= $_REQUEST["key"];	

//获取历史竞价接口
$rs=array("success"=>"1");
$history = array();
if (isset($aid)){
	if (isset($uuid) and strlen($uuid) >= 32){
		$uInfoArr = user_getInfoFromUUID();
		$uid = $uInfoArr["uid"];//用户信息主键
		$mobile = $uInfoArr["mobile"];//用户信息主键
	}
	$sql = "
			SELECT
			u.mobile as nick,
			a.bid,
			a.bid_dt,
			a.is_bid
			FROM
			auction_userbid a left outer join user_base u on a.uid=u.uid
			WHERE
			a.aid = '".$aid."'
			ORDER BY
			a.bid_dt DESC,aubid desc
			limit 10";
	$db->query($sql);
	while($db->next_record()){
		$nick = $db->f("nick");
		$bid = $db->f("bid");
		$bid_dt = $db->f("bid_dt");
		$is_bid = $db->f("is_bid");
		
		if ($uInfoArr and $nick == $mobile){
			//nickname = nick;
			$nickname = substr($nick,0,3)."*****".substr($nick,-3);
			$mine = "1";
		}else {
			$nickname = substr($nick,0,3)."*****".substr($nick,-3);
			$mine = "0";
		}
		
		$history[] = array(
			"name"=>$nickname
			,"time"=>$bid_dt
			,"price"=>$bid
			,"mine"=>$mine
			,"state"=>$is_bid
		);
	}
	$rs=array("success"=>"1","history"=>$history);
}else{
	//"msg":"错误的ID"
	$rs=array("success"=>"0","errCode"=>"0");
}


echo json_encode($rs);
?>
